cmake_minimum_required(VERSION 3.19)
set(PROJECT_NAME "gamepad_rc")

project(${PROJECT_NAME} LANGUAGES CXX)

find_package(Qt6 6.5 REQUIRED COMPONENTS Core  Widgets Gui 3DCore 3DRender 3DExtras Charts)
include(sdl2_mingw64/lib/cmake/SDL2/sdl2-config.cmake)

qt_standard_project_setup()

# 递归查找所有 .c 和 .h 文件
file(GLOB_RECURSE SOURCE_FILES
        "user/*.cpp"
        "user/*.h"
        "Mavlink_V1.0/*.h"
)
qt_add_executable(${PROJECT_NAME}
    WIN32 MACOSX_BUNDLE
        WIN32 MACOSX_BUNDLE
        main.cpp
        ui/mainwindow.ui
        ui/maincharts.ui
        window/mainwindow.cpp
        window/mainwindow.h
        window/maincharts.cpp
        window/maincharts.h
        media.rc
        ${SOURCE_FILES}
)

target_include_directories(
        ${PROJECT_NAME}
        PRIVATE
)

target_link_libraries(${PROJECT_NAME}
    PRIVATE
        Qt::Network
        Qt::Core
        Qt::Widgets
        SDL2::SDL2
        Qt::3DCore
        Qt::Gui
        Qt::3DRender
        Qt::3DExtras
        Qt::3DInput
        Qt::Charts
)

include(GNUInstallDirs)

install(TARGETS ${PROJECT_NAME}
    BUNDLE  DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)


qt_generate_deploy_app_script(
    TARGET ${PROJECT_NAME}
    OUTPUT_SCRIPT deploy_script
    NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
